<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set a time field or several common fields at once</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intlcalendar.roll.html">IntlCalendar::roll</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intlcalendar.setfirstdayofweek.html">IntlCalendar::setFirstDayOfWeek</a></div>
 <div class="up"><a href="class.intlcalendar.html">IntlCalendar</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intlcalendar.set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlCalendar::set</h1>
  <p class="verinfo">(PHP 5.5.0, PECL &gt;= 3.0.0a1)</p><p class="refpurpose"><span class="refname">IntlCalendar::set</span> &mdash; <span class="dc-title">Set a time field or several common fields at once</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlcalendar.set-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>IntlCalendar::set</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$field</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code></span>
   )</div>

  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>IntlCalendar::set</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$month</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$dayOfMonth</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$hour</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$minute</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$second</code><span class="initializer"> = NULL</span></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>intlcal_set</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <code class="parameter">$cal</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$field</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code></span>
   )</div>

  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>intlcal_set</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <code class="parameter">$cal</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$month</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$dayOfMonth</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$hour</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$minute</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$second</code><span class="initializer"> = NULL</span></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   Sets either a specific field to the given value, or sets at once several
   common fields. The range of values that are accepted depend on whether the
   calendar is using the <a href="intlcalendar.setlenient.html" class="link">lenient
   mode</a>.
  </p>
  <p class="para">
   For fields that conflict, the fields that are set later have priority.
  </p>
  <p class="para">
   This method cannot be called with exactly four arguments.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlcalendar.set-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">cal</code></em></dt>

    <dd>

     <p class="para">
      The IntlCalendar resource.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">field</code></em></dt>

    <dd>

     

<p class="para">
 One of the <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> date/time <a href="class.intlcalendar.html#intlcalendar.constants" class="link">field constants</a>. These are integer
 values between <em>0</em> and
 <strong><code>IntlCalendar::FIELD_COUNT</code></strong>.
</p>

    </dd>

   
   
    <dt>
<em><code class="parameter">value</code></em></dt>

    <dd>

     <p class="para">
      The new value of the given field.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">year</code></em></dt>

    <dd>

     <p class="para">
      The new value for <strong><code>IntlCalendar::FIELD_YEAR</code></strong>.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">month</code></em></dt>

    <dd>

     <p class="para">
      The new value for <strong><code>IntlCalendar::FIELD_MONTH</code></strong>.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">dayOfMonth</code></em></dt>

    <dd>

     <p class="para">
      The new value for <strong><code>IntlCalendar::FIELD_DAY_OF_MONTH</code></strong>.
      The month sequence is zero-based, i.e., January is represented by 0,
      February by 1, …, December is 11 and Undecember (if the calendar has
      it) is 12.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">hour</code></em></dt>

    <dd>

     <p class="para">
      The new value for <strong><code>IntlCalendar::FIELD_HOUR_OF_DAY</code></strong>. 
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">minute</code></em></dt>

    <dd>

     <p class="para">
      The new value for <strong><code>IntlCalendar::FIELD_MINUTE</code></strong>.
      </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">second</code></em></dt>

    <dd>

     <p class="para">
      The new value for <strong><code>IntlCalendar::FIELD_SECOND</code></strong>.  
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlcalendar.set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success and <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-intlcalendar.set-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2555">
   <p><strong>Example #1 <span class="function"><strong>IntlCalendar::set()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Europe/Lisbon'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'intl.default_locale'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'pt_PT'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//Calls&nbsp;made&nbsp;later&nbsp;have&nbsp;priority<br /></span><span style="color: #0000BB">$cal&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlGregorianCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">2013</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">6&nbsp;</span><span style="color: #FF8000">/*&nbsp;July&nbsp;*/</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">FIELD_YEAR</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2012</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">FIELD_EXTENDED_YEAR</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2011</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">));<br /><br /><br /></span><span style="color: #0000BB">$cal&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlGregorianCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">2013</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">6&nbsp;</span><span style="color: #FF8000">/*&nbsp;July&nbsp;*/</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">FIELD_YEAR</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2012</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">FIELD_EXTENDED_YEAR</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2011</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//the&nbsp;time&nbsp;has&nbsp;not&nbsp;been&nbsp;recalculated&nbsp;yet.&nbsp;If&nbsp;we&nbsp;clear&nbsp;the&nbsp;extended&nbsp;year,<br />//the&nbsp;year&nbsp;set&nbsp;before&nbsp;will&nbsp;be&nbsp;used<br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">clear</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">FIELD_EXTENDED_YEAR</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">));</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(20) &quot;01/07/2011, 00:00:00&quot;
string(20) &quot;01/07/2012, 00:00:00&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-intlcalendar.set-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="intlcalendar.get.html" class="methodname" rel="rdfs-seeAlso">IntlCalendar::get()</a> - Get the value for a field</span></li>
    <li class="member"><span class="methodname"><a href="intlcalendar.add.html" class="methodname" rel="rdfs-seeAlso">IntlCalendar::add()</a> - Add a (signed) amount of time to a field</span></li>
    <li class="member"><span class="methodname"><a href="intlcalendar.roll.html" class="methodname" rel="rdfs-seeAlso">IntlCalendar::roll()</a> - Add value to field without carrying into more significant fields</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intlcalendar.roll.html">IntlCalendar::roll</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intlcalendar.setfirstdayofweek.html">IntlCalendar::setFirstDayOfWeek</a></div>
 <div class="up"><a href="class.intlcalendar.html">IntlCalendar</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
